﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SGArchiveSystem7x.Controllers
{
    /// <summary>
    /// 控制器基础类，项目中所有控制器必须派生此类
    /// </summary>
    public class BaseController : Controller
    {
        /// <summary>
        /// 即判断用户权限也判断用户SESSION
        /// </summary>
        /// <returns></returns>
        public ActionResult VaildUser(string sControllerName="")
        {
            var n = SessionUser();
            if (n == null && sControllerName != "")
            {
                n = AuthorityUser(sControllerName);
                return n;
            }
            else
                return n;
        }

        /// <summary>
        /// 判断用户权限
        /// </summary>
        public ActionResult AuthorityUser(string sControllerName)
        {
            return null;
            ///return RedirectToAction("Main", "SessionErr");
        }
        /// <summary>
        /// 判断用户SESSION是否过期
        /// </summary>
        /// <returns></returns>
        public ActionResult SessionUser()
        {
            if (SGArchiveSystem7x.App_Code.CSession.Get_User(Session) == null)
                return RedirectToAction("ToSessionErrPage", "Main");
            else
                return null;
        }
    }
}